package com.xbongbong.paas.service.process;

import com.xbongbong.paas.domain.entity.PaasFormDataEntity;
import com.xbongbong.paas.domain.entity.ext.PaasFormEntityExt;
import com.xbongbong.paas.model.PaasFormModel;
import com.xbongbong.paas.pojo.dto.FormDataAddDTO;
import com.xbongbong.paas.pojo.dto.FormDataUpdateDTO;
import com.xbongbong.paas.pojo.vo.AfterSaveVO;
import com.xbongbong.paas.service.impl.DistributorProModelServiceImpl;
import com.xbongbong.paas.toolbox.exception.XbbException;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @author 吴峰
 * @date 2022/07/19 16:59
 */
@Service("processDataService")
public class DistributorProcessDataServiceImpl implements DistributorProcessDataService {

    @Resource
    private PaasFormModel paasFormModel;
    @Resource
    private DistributorProModelServiceImpl distributorProModelService;


    @Override
    public AfterSaveVO insert(FormDataAddDTO formDataAddDTO, PaasFormDataEntity paasFormDataEntity) throws XbbException {

        PaasFormEntityExt paasFormEntityExt = paasFormModel.getByKey(formDataAddDTO.getFormId(), formDataAddDTO.getCorpid());
        return distributorProModelService.insert(formDataAddDTO, paasFormDataEntity, paasFormEntityExt);
    }

    @Override
    public AfterSaveVO update(FormDataUpdateDTO formDataUpdateDTO, PaasFormDataEntity paasFormDataEntity , PaasFormDataEntity oldFormData) throws XbbException {
        PaasFormEntityExt paasFormEntityExt = paasFormModel.getByKey(formDataUpdateDTO.getFormId(), formDataUpdateDTO.getCorpid());
        return distributorProModelService.update(formDataUpdateDTO, paasFormDataEntity, oldFormData, paasFormEntityExt);
    }
}
